// pages/marketPage/marketPage.js
//var http = require('../../utils/httpHelper.js');
var wallet  = require('../wallet.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
      marketLang:{},
      marketData:[],
      tid:'2'
  },
  getMarket() {
    var $this = this
    wallet.post('/market/ticker', {}, function (res) {
      console.log(res.data)
       $this.setData({
          //iconNum: res.data
          marketData:res.data
        })
      
    })
  },
  marketEventListener(e){

  },
  goNav(e) {
    //console.log(e)
    let id = e.currentTarget.id
    this.setData({
      tid: id
    })
    switch (id) {
      case '1':
        wx.reLaunch({
          url: '../assetPage/assetPage'

        })
        break;
      case '2':
        // wx.reLaunch({
        //   url: '../marketPage/marketPage'

        // })
        break;
      case '3':
        wx.reLaunch({
          url: '../transactionPage/transactionPage'

        })
        break;
      case '4':
        wx.reLaunch({
          url: '../myPages/myPages'
        })
        break;
      default:
        break;
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // this.timer2 = setInterval(this.getMarket,300)
    //this.getMarket();
 
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getMarket && this.getMarket()
     //this.timer2 = setInterval(this.getMarket, 2000)
    wx.setNavigationBarTitle({
      title: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].JLXXMarketQuotations : wx.T.locales['en'].JLXXMarketQuotations
    })
    wx.setTabBarItem({
      index: 1,
      text: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].JLXXMarketQuotations : wx.T.locales['en'].JLXXMarketQuotations,
      iconPath: "image/tab_hangqing_normal.png",
      selectedIconPath: "image/tab_hangqing_selected.png"
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    this.timer2 && clearInterval(this.timer2)
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    this.timer2 && clearInterval(this.timer2)
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})